﻿<?php 
if ($data['act'] == 'detail'):?>
<article class="detail">
	<?php if(isset($data['detail']) && count($data['detail'])):?>
		<h1><?php echo $data['detail']['NewsI18n'][$sf_user->getCulture()]['title']?></h1>
		<time datetime="<?php echo DateHelper::dateFormatFree($data['detail']['updated_at'],'Y-m-d')?>"><?php echo DateHelper::dateFormat($data['detail']['updated_at'])?></time>
		<?php if (!empty($data['detail']['photo_url'])):?>
		<img src="<?php echo $data['detail']['photo_url']?>" title="<?php echo $data['detail']['NewsI18n'][$sf_user->getCulture()]['title']?>" alt="<?php echo $data['detail']['NewsI18n'][$sf_user->getCulture()]['title']?>"/>
		<h6><?php echo $data['detail']['NewsI18n'][$sf_user->getCulture()]['title']?></h6>
		<?php endif?>
		<div class="content">
			<?php echo html_entity_decode($data['detail']['NewsI18n'][$sf_user->getCulture()]['content'])?>
		</div>
	<?php else:	?>
	<script type="text/javascript">
	window.location = '<?php echo url_for2('news')?>';
	</script>
	<?php endif;?>
</article>
<div class="clr"></div>
<?php if (count($data['news'])):?>
<div class="news-more">
	<h3>Những chia sẻ liên quan mới nhất</h3>
	<ul>
	<?php foreach ($data['news'] as $news):?>
		<li><a title="<?php echo $news['title']?>" alt="<?php echo $news['title']?>" href="<?php echo url_for2('news_detail', array('id' => $news['id'], 'cate_id' => $news['cate_id'], 'title' => UserStringHelper::titleToAddress($news['title'])))?>"><h4> &raquo; <?php echo $news['title']?></h4></a></li>
	<?php endforeach; ?>
	</ul>
</div>
<?php endif;
else:
$count_for = 0;
$perpage = intval($data['perpage']);
foreach($data['news'] as $pr){
	$item = array(
		'title'			=> $pr['title'],
		'photo_url'	=> $pr['photo_url'],
		'id'				=> $pr['id'],
		'description' => $pr['description'],
		'clear'			=> (++$count_for % $perpage == 0? htmlentities('<div class="clr"></div>'): ''),
		'href'				=> url_for2('news_detail', array('cate_id' => $pr['cate_id'],'id' => $pr['id'], 'title' => UserStringHelper::titleToAddress($pr['title'])))
	);
	
	include_component('componentUlti', 'newsItem',array('data' => $item));
}?>
<div class="clr"></div>

<?php include_component('componentUlti', 'pagination',$data['pagination']);?>
<div class="clr"></div>
<?php endif;?>